package com.goldgov.sensitive.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.goldgov.securityworkbench.dict.bean.dto.DictDto;
import com.goldgov.securityworkbench.dict.bean.dto.DictQuery;
import com.goldgov.securityworkbench.dict.dao.IDictDao;
import com.goldgov.sensitive.dao.SensitiveDao;
import com.goldgov.sensitive.service.Sensitive;
import com.goldgov.sensitive.service.SensitiveQuery;
import com.goldgov.sensitive.service.SensitiveService;

@Service
public class SensitiveServiceImpl implements SensitiveService {

	@Autowired
	private SensitiveDao dao;
	
	@Autowired
	private IDictDao dictDao;
	
	@Override
	public Sensitive getSensitiveID(){
		return dao.getSensitiveID();
	}
	
	@Override
	public String addSensitive(Sensitive obj){
		dao.addSensitive(obj);
		return null;
	}
	
	@Override
	public void deleteSensitive(String[] ids){
		dao.deleteSensitive(ids);
	}
	
	@Override
	public Sensitive getSensitive(String id){
		return dao.getSensitive(id);
	}
	
	@Override
	public List<Sensitive> listSensitive(SensitiveQuery query){
		return dao.listSensitive(query);
	}
	
	@Override
	public String judgeSensitive(String value) {
		StringBuffer sb=new StringBuffer();
		DictQuery query=new DictQuery();
		query.setQueryDictCode(SensitiveQuery.MGC_TYPE);
		List<DictDto> list=dictDao.findDictListByPage(query);
		for(DictDto d:list) {
			if(value.indexOf(d.dictValue)!=-1) {
				sb.append(d.dictValue+"，");
			}
		}
		return sb.toString().equals("")?sb.toString():sb.substring(0,sb.length()-1);
	}
}